package 暴力递归;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class PrintAllSubsquences_distinct {
    public static List<String> subsNoRepeat(String s){
        char[] str = s.toCharArray();
        String path = "";
        HashSet<String> set = new HashSet<>();
        process(str,0,set,path);
        List<String> ans = new ArrayList<>();
        for (String cur : set ){
            ans.add(cur);
        }
        return ans;
    }


    public static void process(char[] str,int index,HashSet<String> set,String path){
        if (index == str.length){
            set.add(path);
            return;
        }
        process(str,index+1,set,path);
        process(str,index+1,set,path + String.valueOf(str[index]));
    }
}
